package com.acme.task6;

public class CommentaryRemover {
	private static final String TOO_FEW_ARGUMENTS = "TOO FEW ARGUMENTS";

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if (args.length < 1)
			throw new IllegalArgumentException(TOO_FEW_ARGUMENTS);
		String stringWithComments = args[0];
		boolean longComment = false;
		boolean rowComment = false;
		for (int i = 0; i < stringWithComments.length(); i++) {
			char c = stringWithComments.charAt(i);

			if (!rowComment && !longComment) {
				// checking start of commentary
				if (c == '/') {
					if (i + 1 < stringWithComments.length()) {
						if (stringWithComments.charAt(i + 1) == '/') {
							rowComment = true;
							i++;
							continue;
						}
						if (stringWithComments.charAt(i + 1) == '*') {
							longComment = true;
							i++;
							continue;
						}
					}
				}
				System.out.print(c);
			}

			// checking ending of the commentary
			if (rowComment && c == '\n') {
				rowComment = false;
				continue;
			}

			if (longComment && c == '*') {
				if (i + 1 < stringWithComments.length()
						&& stringWithComments.charAt(i + 1) == '/') {
					longComment = false;
					i++;
					continue;
				}
			}

		}
	}
}
